﻿#include "stdafx.h"
#include "PlayerMe.h"
#include "Terrain.h"
#include "MuNetConnect.h"

PlayerMe::PlayerMe()
{
	m_lifeType = LifeType::me;
	m_animIndex.idle = 1;
	m_animIndex.move = 13;
}


PlayerMe::~PlayerMe()
{
}

void PlayerMe::Init(MuType::CharacterClass muclass, Camera *camera, Shader *shader)
{
	PlayerObject::Init(muclass, camera, shader);
	m_fsm = new FSMPlayerMe(this);
}

bool PlayerMe::MakePath(POINT start, POINT end, std::list<POINT> &result)
{
	bool fok = LifeObject::MakePath(start, end, result);
	if (fok)
	{
		std::vector<u_char> dirs;
		dirs.reserve(result.size());
		auto it1 = result.begin();
		auto it2 = it1;
		auto itEnd = result.end();
		for (++it2; it2 != itEnd; ++it2)
		{
			dirs.push_back(CalcDir(*it1, *it2));
			it1 = it2;
		}
		MuNetConnect::GetInstance()->SendMovePosDirs(start, dirs);
	}
	return fok;
}